home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / vol16n13.zip / OPENTR.ZIP / OT_SRC.ZIP / OPTDLG.CPP < prev    next >
C/C++ Source or Header  |  1997-05-26  |  3KB  |  130 lines

  1. // OptDlg.cpp : implementation file
  2. //
  3. // This module implements the Logging Options dialog box.
  4. // OpenTrap Version 1.00 by Gregory A. Wolking
  5. // Copyright ⌐ 1997 Ziff-Davis Publishing
  6. // First published in PC Magazine, US Edition, July 1997.
  7.  
  8. #include "stdafx.h"
  9. #include "OpenTrap.h"
  10. #include "OptDlg.h"
  11. #include "OTextern.h"
  12.  
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // COptDlg dialog
  21.  
  22.  
  23. COptDlg::COptDlg(CWnd* pParent /*=NULL*/)
  24.     : CDialog(COptDlg::IDD, pParent)
  25. {
  26.     //{{AFX_DATA_INIT(COptDlg)
  27.     m_intLogSize = 1;
  28.     m_bSaveSettings = FALSE;
  29.     m_intVM = -1;
  30.     m_intAction = -1;
  31.     m_bErrorsOnly = FALSE;
  32.     m_bHide = FALSE;
  33.     //}}AFX_DATA_INIT
  34. }
  35.  
  36.  
  37. void COptDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39.     CDialog::DoDataExchange(pDX);
  40.     if (g_intRecCount)
  41.     {
  42.         min_buf_size_K = (g_pNextRec - g_pBufferStart) / 1024 + 1;
  43.         if (min_buf_size_K > 2048)
  44.             min_buf_size_K = 2048;
  45.         if (min_buf_size_K < 64)
  46.             min_buf_size_K = 64;
  47.     }
  48.     else
  49.         min_buf_size_K = 64;
  50.     //{{AFX_DATA_MAP(COptDlg)
  51.     DDX_Control(pDX, IDC_lblBuf2, m_lblBuf2);
  52.         DDX_Text(pDX, IDC_txtLogSize, m_intLogSize);
  53.     DDV_MinMaxUInt(pDX, m_intLogSize, min_buf_size_K, 2048);
  54.         DDX_Check(pDX, IDC_chkSaveSettings, m_bSaveSettings);
  55.     DDX_Radio(pDX, IDC_optVM1, m_intVM);
  56.     DDX_Radio(pDX, IDC_optAction1, m_intAction);
  57.     DDX_Check(pDX, IDC_chkLogErrorsOnly, m_bErrorsOnly);
  58.     DDX_Check(pDX, IDC_chkHide, m_bHide);
  59.     //}}AFX_DATA_MAP
  60. }
  61.  
  62.  
  63. BEGIN_MESSAGE_MAP(COptDlg, CDialog)
  64.     //{{AFX_MSG_MAP(COptDlg)
  65.     ON_WM_CONTEXTMENU()
  66.     //}}AFX_MSG_MAP
  67.     ON_COMMAND(ID_CONTEXT_HELP, OnContextHelp)
  68. END_MESSAGE_MAP()
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // COptDlg message handlers
  72.  
  73. BOOL COptDlg::OnInitDialog() 
  74. {
  75.     int buf_free_K;
  76.     CString txt;
  77.  
  78.     CDialog::OnInitDialog();
  79.  
  80.     if (g_bLogFull)
  81.         txt = "Buffer is full";
  82.     else
  83.     {
  84.         buf_free_K = g_intLogSizeK - ((g_pNextRec - g_pBufferStart) / 1024);
  85.         txt.Format("(%uKB free)", buf_free_K);
  86.     }
  87.     m_lblBuf2.SetWindowText(txt);
  88.     return TRUE;  // return TRUE unless you set the focus to a control
  89.                   // EXCEPTION: OCX Property Pages should return FALSE
  90. }
  91.  
  92. void COptDlg::OnOK() 
  93. {
  94.     // TODO: Add extra validation here
  95.     if (!UpdateData(TRUE))
  96.     {
  97.         m_intLogSize = g_intLogSizeK;
  98.         UpdateData(FALSE);
  99.         return;
  100.     }
  101.     CDialog::OnOK();
  102. }
  103.  
  104. void COptDlg::OnContextMenu(CWnd* pWnd, CPoint point)
  105. {
  106.     CPoint ptClient = point;
  107.     CWnd* wndTarget;
  108.     UINT id = 0;
  109.     ScreenToClient(&ptClient);
  110.     wndTarget = ChildWindowFromPoint(ptClient, CWP_SKIPTRANSPARENT);
  111.     if (wndTarget == this)
  112.         wndTarget = ChildWindowFromPoint(ptClient);
  113.     if (wndTarget)
  114.         id = wndTarget->GetDlgCtrlID();
  115.     if (id == 0 || id == IDOK || id == IDCANCEL)
  116.         return;
  117.     else
  118.         m_intHelpContext = id + 0x40000;
  119.     CMenu my_menu;
  120.     my_menu.CreatePopupMenu();
  121.     my_menu.AppendMenu(MF_ENABLED, ID_CONTEXT_HELP, "What's this?");
  122.     my_menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, this);
  123. }
  124.  
  125. void COptDlg::OnContextHelp()
  126. {
  127.     WinHelp(m_intHelpContext, HELP_CONTEXTPOPUP);
  128. }
  129.  
  130.